﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace EnvironmentManagerSystem
{
    public partial class ChangePassword : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (StfInfo.ReSession()) return; if (!IsPostBack)
            {
                string aa = Session["UID"].ToString();
                lblLoginName.Text = aa;
            }
        }
        #region LinkButton_Click
        protected void lbtnQueRen_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable dt = EnvironmentManagerSystem.BLL.User.login(lblLoginName.Text.Trim(), txtPassword.Text.Trim());
                if (dt.Rows.Count > 0)
                {
                    if (txtpwd.Text.Trim() == txtAgainpwd.Text.Trim())
                    {
                        bool dr = EnvironmentManagerSystem.BLL.User.UpdatePassword(txtAgainpwd.Text.Trim(), lblLoginName.Text.Trim());
                        if (dr == true)
                        {
                            Jscript.Alert("修改密码成功！", this);
                        }
                        else
                        {
                            Jscript.Alert("修改密码失败！", this);
                        }
                    }
                    else
                    {
                        Jscript.Alert("两次密码不一致！", this);
                    }
                }
                else
                {
                    Jscript.Alert("原密码不正确！", this);
                }
            }
            catch { }
        }
        #endregion

        protected void lbtnQuXiao_Click(object sender, EventArgs e)
        {
            txtPassword.Text = "";
            txtpwd.Text = "";
            txtAgainpwd.Text = "";

        }      
    }
}
